<?php
namespace Home\Controller;
use Common\Controller\AuthController;
class IndexController extends AuthController {
    public function index(){//后台首页
	    $this->display();
    }
    public function xgpass(){//修改密码的页面
		$Admin = D("admin");
		$where['id'] = "1";
		$result = $Admin->where($$where)->find(); 
		$this->assign('result',$result);
		$this->display();
    }
	public function tjpass(){//修改密码方法
		if(IS_POST){
			$Admin = D("admin");
			if(!$Admin->create($_POST,4)){
				$error = $Admin->getError();
				$this->error($error,U('Index/xgpass'),1);
			}else{
				$where['id'] = $_POST['id'];
				$map['user'] = $_POST['user'];
				$map['pwd'] = md5($_POST['pwd']);
				$result = $Admin->where($where)->save($map);
				if($result){
					$this->success("修改成功！",U('Index/index'));
				}else{
					$this->error("修改失败!",U('Index/xgpass'));
				}
			}
		}else{
			$this->error("修改失败!",U('Index/xgpass'));
		}
    }	
}

